import execjs
import json
import os


def merge(file1, file2):
    f1 = open(file1, 'a+', encoding='utf-8')
    with open(file2, 'r', encoding='utf-8') as f2:
        f1.write('\n')
        for i in f2:
            f1.write(i)

filename = 'settings_temp.js'
with open(filename, 'w') as f:
    f.write("window = {};\n")

merge(filename, 'settings.js')

with open(filename, 'r', encoding='UTF-8') as f:
    js_code = f.read()
context = execjs.compile(js_code)
result = context.eval("window._CCSettings")

with open("settings.json", 'w') as write_f:
    json.dump(result, write_f, separators=(',', ':'))

os.system('7z a settings.zip ' + "settings.json")
